package cn.waters321.rock.generator.config;

import java.util.List;
import com.baomidou.mybatisplus.generator.config.rules.DbType;
import lombok.Data;

@Data
public class BaseInfo {

  protected String dbType;
  protected String url;
  protected String userName;
  protected String password;
  protected List<String> excludeTables;
  protected String entitySuperClass;
  protected List<String> publicColumn;

  protected String driverName = "com.mysql.jdbc.Driver";
  protected DbType dbTypeEnum = DbType.MYSQL;

  protected void setDbType(String dbType) {
    if ("mysql".equals(dbType)) {
      this.driverName = "com.mysql.jdbc.Driver";
      this.dbTypeEnum = DbType.MYSQL;
    } else if ("postgresql".equals(dbType)) {
      this.driverName = "org.postgresql.Driver";
      this.dbTypeEnum = DbType.POSTGRE_SQL;
    } else if ("oracle".equals(dbType)) {
      this.driverName = "oracle.jdbc.driver.OracleDriver";
      this.dbTypeEnum = DbType.ORACLE;
    } else if ("sqlserver".equals(dbType)) {
      this.driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
      this.dbTypeEnum = DbType.SQL_SERVER;
    }
  }

}
